package com.ruoyi.web.core.config;

import com.ruoyi.web.utils.ConstUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: likailun
 * @Description:    
 * @Date: create in 2024/4/17 20:30
 */
@Configuration
public class ThymeleafConfig implements WebMvcConfigurer {
    @Autowired
    @Qualifier("thymeleafViewResolver")
    private ThymeleafViewResolver thymeleafViewResolver;

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        if (thymeleafViewResolver != null) {
            Map<String, Object> map = new HashMap<>();
            map.put("v", ConstUtil.VERSION);
            thymeleafViewResolver.setStaticVariables(map);
        }
    }
}
